from django.conf.urls import url
from django.urls import path, include
from django.views.generic import RedirectView

from Main import views

# 注册CBV视图
# router = DefaultRouter()
# router.register('motto', MottoViewSet)

drf_patterns = [
    # 第一个介绍方块 api
    path('api/v1/motto/', views.MottoView.as_view(), name='motto_api'),
    # 第二个文章方块，传默认最近访问的6个文章 api
    path('api/v1/article/', views.ArticleView.as_view(), name='article_api'),
    # 根据类别展示文章 api
    path('api/v1/article_cate/', views.ArticleCateView.as_view(), name='article_cate_api'),
    # 获取所有文章类型
    path('api/v1/get_article_cate/', views.ArticleCate.as_view(), name='get_article_cate_api'),
    # 获取文章内容api
    path('api/v1/article_content/', views.ArticleContentView.as_view(), name='article_content_api'),
    # 验证权限
    path('api/v1/auth/', views.AuthView.as_view(), name='auth_api'),
]

urlpatterns = [
    # 直接输入IP或者域名进行跳转
    # url(r'^$', views.index, name='default'),
    url(r'^$', RedirectView.as_view(url='/static/dist/homepage/homepage_index.html')),
    path('index/', views.index, name='index'),
    # path('mdeditor/', views.mdeditor, name='mdeditor'),
    path('article/<str:articleid>/', views.article_page, name='article_page'),
    # 导入drf_patterns
    path('', include(drf_patterns)),
]
